{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Coding with Qiskit Episode 3\n",
    "\n",
    "# Hello World!"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "In this episode of Coding with Qiskit, we built our first Hello World application.\n",
    "\n",
    "The application first entangled two qubits which were initially in the state $\\vert00\\rangle$. Then, we noted the results by running the application on a simulator as well as real quantum hardware at IBM.\n",
    "\n",
    "This Jupyter notebook shows the code that was used in the video, as well as updates in the latest version of Qiskit.\n",
    "\n",
    "**Link to Episode 3:** https://www.youtube.com/watch?v=RrUTwq5jKM4"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "        <iframe\n",
       "            width=\"960.0\"\n",
       "            height=\"540.0\"\n",
       "            src=\"http://www.youtube.com/embed/RrUTwq5jKM4\"\n",
       "            frameborder=\"0\"\n",
       "            allowfullscreen\n",
       "        ></iframe>\n",
       "        "
      ],
      "text/plain": [
       "<IPython.lib.display.IFrame at 0x109c62eb8>"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from IPython.display import IFrame\n",
    "IFrame(src=\"http://www.youtube.com/embed/RrUTwq5jKM4\", width=1920/2, height=1080/2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Building the circuit"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We begin by importing Qiskit."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "from qiskit import *"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "In the video, we initialized two qubits into a `QuantumRegister` and two classical bits into a `ClassicalRegister` by writing"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "qr = QuantumRegister(2)\n",
    "cr = ClassicalRegister(2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Then we built a `QuantumCircuit` composed of the two classical and quantum bits by saying"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "circuit = QuantumCircuit(qr, cr)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The above three lines of code can be simplified into one line by writing"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "circuit = QuantumCircuit(2,2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "where the first argument is the number of quantum bits, and the second argument is the number of classical bits. This is the recommended way of creating circuits."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Once you create your circuit, you can draw it at any point by writing"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<pre style=\"word-wrap: normal;white-space: pre;background: #fff0;line-height: 1.1;font-family: &quot;Courier New&quot;,Courier,monospace\">        \n",
       "q_0: |0>\n",
       "        \n",
       "q_1: |0>\n",
       "        \n",
       " c_0: 0 \n",
       "        \n",
       " c_1: 0 \n",
       "        </pre>"
      ],
      "text/plain": [
       "<qiskit.visualization.text.TextDrawing at 0x12c414e80>"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "circuit.draw()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "For a plot based on `matplotlib`, use instead"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAIQAAACoCAYAAAAhKkbqAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW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g==\n",
      "text/plain": [
       "<Figure size 156.52x204.68 with 1 Axes>"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "%matplotlib inline \n",
    "circuit.draw(output='mpl')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Note that you only need to run the `%matplotlib inline` command once in your notebook."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Next, let's add the gates."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAToAAACoCAYAAABwmyKgAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjAsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+17YcXAAAURklEQVR4nO3de1TUdcLH8fdwFRFBQiXCG95BQQSLXJPIzbDas2amSfkk2apoZ7W2PdXZdbe2k+utU9sp006az9aup1Axe8q11CCTMklJSY31QogpCmguKiCX5w8WclRk1Bl+8p3P65w5Z/jNd37zAWY+fH+XGWx1dXV1iIgYzMPqACIirqaiExHjqehExHgqOhExnopORIynohMR46noRMR4KjoRMZ6KTkSMp6ITEeOp6ETEeCo6ETGeik5EjKeiExHjqehExHgqOhExnopORIynohMR46noRMR4KjoRMZ6KTkSMp6ITEeOp6ETEeCo6ETGeik5EjKeiExHjqehExHheVgcQx8z6hzWP+8pD1jyulWw2myWPW1dXZ8njugPN6ETEeCo6ETGeik5EjKeiExHjqehExHgqOhExnk4vEblGbdu2ZcCAAQQGBlJdXc3+/fspLCxscnxsbCyhoaGsW7euBVO6NxWdyFUIDAzkkUceITU1lYEDB+Lp6Wl3e0lJCR9++CGLFi0iJyencXlsbCwbNmzA39+f4cOH8/XXX7d0dLdkq9NZiq2Cu5wwXFQGeUVQVQ0hATC4O7TxbtkM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8RYlcszdSQl4eNjPNm9PGGRkyYGKrlF1dTUPPfQQo0ePZteuXYwZM4aZM2cSGxvLqlWrOHz4sNURXWJj9nba+Prwi/gBVkdptX45LI42vj6NX98xNJYA/7YWJmpex+Aghg7++Xce1L4dtw2JtjCRa2nT9b/S0tJYvHgxjz/+OC+//LLdW1uKiooIDAwkICDAJY/9zLw3XbJeEdPNfXqKQ+N0wjCwefNmFi9eTHJyMq+++upFO5BddbhfRFqGZnTA/fffz+rVq8nNzSUmJsbqOC3ix+ISXl2+ml/+Io5fDouzOo4RjpWcoOMNQa3q1Iya2lrKTp6iY3CQ1VFcSkUHBAQEEBISwsGDBy15fG26ilwdRzdd3f5gxMmTJykvL6d79+5WRxERF3H7Gd2JEycIDg4mMjKS7777zuo4LeKdjE/Y/8OPPD1tAn5tfK2OI+Jybj+j69ChAxEREezZs4cNGzZcdPv3339vQSrX+bG4hO/yCxgWP1AlJ25DR12Bv/71r4wfP55Ro0bx61//mp49e3Ls2DGys7OJjIwkIyPD6ohOU3byPwQHBei8OXErbr/p2mD9+vUsWLCAbdu2UVFRQadOnbj55puZNWsWt912m9XxnKq2tlbvhBC3oqITEePpz7qIGE9FJyLGU9GJiPFUdCJiPBWdiBhPRScixlPRiYjxVHQiYjwVnYgYT0UnIsZT0YmI8VR0ImI8FZ2IGE9FJyLGU9GJiPFUdCJiPBWdiBhPRScixlPRiYjxVHQiYjwVnYgYT0UnIsZT0YmI8VR0ImI8FZ2IGE9FJyLGU9GJiPH+H3EGvIbsJf2uAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 397.32x204.68 with 1 Axes>"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# the quantum circuit has two qubits. they are indexed as qubits 0 and 1\n",
    "circuit.h(0)\n",
    "circuit.cx(0,1) # order is control, target\n",
    "circuit.measure([0,1], [0,1]) # qubits [0,1] are measured and results are stored in classical bits [0,1] in order\n",
    "circuit.draw(output='mpl')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Running on a simulator"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We begin by setting the simulator to `qasm_simulator` from the Aer element of Qiskit."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "simulator = Aer.get_backend('qasm_simulator')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Then, we execute the circuit on the simulator and store the results in a variable called `result`."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "result = execute(circuit, backend=simulator).result()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "At this point, we are ready to plot the results of the simulator execution. To do this, first import the visualization tools from Qiskit using"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "from qiskit.visualization import plot_histogram"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Then, we plot the results using"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAc0AAAE6CAYAAAB00gm8AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjAsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+17YcXAAAgAElEQVR4nO3dfZyXdZ3v8ddH5NYAGWRxRhcQQRqEpVGrtRQz04w9bXlT1qG02vKkrVruHquTW9Yp9xy7OVppqac77WbNJLNWNh8uPRYVywScQKZZaAQOMBB3CQoyOH7OH78fNIwzwzUwdwyv5+Pxe8zv972+1zWfy/Hn2+u6vtf3isxEkiTt3xG9XYAkSYcKQ1OSpIIMTUmSCjI0JUkqyNCUJKkgQ1OSp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QiXtFRG3Uxo1+wSwKjO3tdHn6Mz8U48X1884elatTQWeoXS7CVA6zZOZqzLzx8BbKZ2qfUcv1SephYh4N/Ah4MuUJiL5YkRcEBEnlq9x7rnW+b09t4/pwHmkqX2Uv1y/AIZRmvXnD62nyCtPevB3mfmqXihRUgsRcSelWbpuAi4ELgNOBOqBB4F/B6YAt2TmoN6qs7/wSFP7yMydwKeAocBdwKUR8ZcR8QrYO5jgLGBp71UpCSAijqR0ZuhPmdmQmV/KzOnAq4H/oBSgPwa+Btzde5X2Hx5pqk3l0zj/BPwtpYnaHwc2Am8CGoEPZuaS3qtQEkBEjALGZubvyzN27W45ICgiLgF+BJySmU/1Vp39haGpDpVvP/kb4O2UpsxbCtybmb/v1cIktas8a1dkZnNEfIjSqdlhvV1Xf2BoqjAfASYdeiLiWmBAZn6xt2vpDwxNSerHImIg0Oz/8HYNQ1OSpIIcPStJUkGGpiRJBRmakiQVZGhKklSQoSlJUkGGpiRJBf1/l4rhBnBZIJEAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 504x360 with 1 Axes>"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "plot_histogram(result.get_counts(circuit))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Running on real quantum hardware"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "In order to run the circuit on real quantum hardware at IBM, we begin by loading our saved IBMQ account using"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "IBMQ.load_account()\n",
    "provider = IBMQ.get_provider(hub = 'ibm-q')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Then, we choose the backend that we want to use in our run. In the video, we used"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [],
   "source": [
    "qcomp = provider.get_backend('ibmq_16_melbourne')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Generally, if you have no preference on which backend you'd like to use, you can just ask for the least busy backend by using"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "ibmq_16_melbourne\n"
     ]
    }
   ],
   "source": [
    "num_qubits = 2\n",
    "\n",
    "from qiskit.providers.ibmq import least_busy\n",
    "possible_devices = provider.backends(filters=lambda x: \n",
    "                                     x.configuration().n_qubits >= num_qubits\n",
    "                                       and \n",
    "                                     x.configuration().simulator == False)\n",
    "qcomp = least_busy(possible_devices)\n",
    "print(qcomp)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Once the backend is selected, we are ready to run the circuit just as before using the `execute` function. Before doing so, a useful feature is to run the job watcher that is available in the latest version of Qiskit using"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import qiskit.tools.jupyter\n",
    "%qiskit_job_watcher"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [],
   "source": [
    "job = execute(circuit, backend=qcomp)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "You can also monitor the job progress inline using the job monitor:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Job Status: job has successfully run\n"
     ]
    }
   ],
   "source": [
    "from qiskit.tools.monitor import job_monitor\n",
    "job_monitor(job)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Once the job runs sucessfully, we can visualize the results using `plot_histogram` as before using"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAc0AAAE6CAYAAAB00gm8AAAABHNCSVQICAgIfAhk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BHYQnJodAZxJ8IF9r/7jJ1YL+6QIOIuga8Oj7r4waQV2YGaWCeyJ/mCOHHmeApwKDCc4M6D/MwnS3D5pps0pBDcK/TTyTOSTikIzRUSOVvYQnLIoiZqWB3ye4DrAIOBr7r48aYV2IK3sk37A+QRHl/0Jnu+qfZJgZvZDgjs0PyLoD3hU31gz6+XuO9VHMzFC7pOe7v6nhBcXJ7p7NnUMBTYQdDcBgvP/7l7p7q8CXyY4VXttkurriFraJ39w99cIrpXtQfsk4czs6wR/tDwG/JygO8MEMxscuZ6GmZ0KPGtmIxSYba+FfXKNmZ0RtU+6AM81dKc7GelIM0VE/jG9STBwwRTg902HyDOzO4G/dfdzklBih6N9krrMbB5QD8wGJgBTgTOAcuBXwP8SDHjwhLtnJKvOjqSj7BMdaaaIyJim/wJ0AZ4HppjZZyN/LTdcPL+YoE+aJID2SWqK9M3cAPzJ3Svc/d/dfQTwOYJh86YSdNP6PhrUICE60j7RkWaKiZy2uA/4CsFA7UuBGoKxZ6uBae6+KnkVdjzaJ6knMhZwn8iYshnAwSY3BF1HMKThSHdfkaw6O5KOsk8Umikq0tXhKuCrBLfNrwZec/dPklpYB6Z9ktoid86au9eb2d8RnAbsmuy6OrL2uE8UmicB0yPAUo72SWozsxlAmrs/muxaJNBe9olCU0TanciTM+r1h03qaC/7RKEpIiISku6eFRERCUmhKSIiEpJCU0REJCSFpoiISEgKTRERkZAUmiIiIiH9f+s3oPm6IkHkAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 504x360 with 1 Axes>"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "result = job.result()\n",
    "plot_histogram(result.get_counts(circuit))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "You can close the job watcher window by using"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [],
   "source": [
    "%qiskit_disable_job_watcher"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# References"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "For detailed information about Qiskit, check out the tutorials in the Github repository:\n",
    "\n",
    "https://github.com/Qiskit/qiskit-iqx-tutorials"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Version"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "It's good to note the Qiskit version that was used in your work. One way to do this is print the version at the bottom of the Jupyter notebook using"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'qiskit-terra': '0.9.0',\n",
       " 'qiskit-ignis': '0.2.0',\n",
       " 'qiskit-aqua': '0.6.0',\n",
       " 'qiskit': '0.12.0',\n",
       " 'qiskit-aer': '0.3.0',\n",
       " 'qiskit-ibmq-provider': '0.3.2'}"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "qiskit.__qiskit_version__"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div style='width: 100%; background-color:#d5d9e0;padding-left: 10px; padding-bottom: 10px; padding-right: 10px; padding-top: 5px'><h3>This code is a part of Qiskit</h3><p>&copy; Copyright IBM 2017, 2019.</p><p>This code is licensed under the Apache License, Version 2.0. You may<br>obtain a copy of this license in the LICENSE.txt file in the root directory<br> of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.<p>Any modifications or derivative works of this code must retain this<br>copyright notice, and modified files need to carry a notice indicating<br>that they have been altered from the originals.</p></div>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "%qiskit_copyright"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
